package test10;

class Money{
    public  double m=12.5;
}
class Person implements Cloneable{
    public int age;
    public Money money=new Money();
    public void eat(){
        System.out.println("吃");
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Test10 {

    public static void main(String[] args) throws CloneNotSupportedException{
        Person person=new Person();
        Person person1=(Person) person.clone();
        System.out.println(person.money.m);//12.5
        System.out.println(person1.money.m);//12.5
        System.out.println("=====");
        person1.money.m=99.9;
        System.out.println(person.money.m);//99.9
        System.out.println(person1.money.m);//99.9

    }



    public static void main1(String[] args) throws CloneNotSupportedException {
        Person person=new Person();
        person.age=99;
        Person person1=(Person) person.clone();
        System.out.println(person1);

        System.out.println("========");
        person1.age=199;
        System.out.println(person);
        System.out.println(person1);
    }
}
